package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entity.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

public interface SkuMapper extends BaseMapper<Sku> {
    @Update("UPDATE tb_sku SET stock = stock - #{num}, sold = sold + #{num} WHERE id = #{id} and saleable = 1")
    void deductStock(Map<String, Object> param);

    @Update("UPDATE tb_sku SET stock = stock - #{num}, sold = sold + #{num} WHERE id = #{id} and saleable = 1")
    void deductStock1(@Param("id") Long id, @Param("num") Integer num);
}